﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using F_SER.DAL;
using System.Data;

namespace F_SER.ServicePorts
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“ServiceHSH”。
    /// <summary>
    /// 会生活接口
    /// </summary>
    public class ServiceHSH : IServiceHSH
    {
        Service1 Service = new Service1();
        Module.SysInfo sysInfo = new Module.SysInfo();
        /// <summary>
        /// 查询指定账户余额
        /// </summary>
        /// <param name="admin">授权账号</param>
        /// <param name="pwd">授权Key</param>
        /// <param name="cardId">卡号</param>
        /// <param name="cardPwd">卡密码</param>
        /// <returns></returns>
        public string SelectBalance(string admin, string pwd, string cardId, string cardPwd)
        {

            sysInfo.CMD="03";
            sysInfo.value01=admin;
            sysInfo.value02=pwd;
            sysInfo.value04 = cardId;
            sysInfo.value07 = cardPwd;
           DataSet dataSet= Service.TableSelect("[ZP_Ports]", CodeHelper.xml(sysInfo));
           return dataSet.Tables[0].Rows[0][0].ToString();
        }

        /// <summary>
        /// 缴费接口
        /// </summary>
        /// <param name="admin">授权账号</param>
        /// <param name="pwd">授权Key</param>
        /// <param name="cardId">卡号</param>
        /// <param name="cardPwd">卡密码</param>
        /// <param name="type">缴费类型</param>
        /// <param name="money">缴费金额</param>
        /// <returns></returns>
        public bool Payment(string admin, string pwd, string cardId, string cardPwd, int type, string money)
        {
            bool reslut = false;
            sysInfo.CMD = "04";
            sysInfo.value01 = admin;
            sysInfo.value02 = pwd;
            sysInfo.value04 = cardId;
            sysInfo.value05 = money;
            sysInfo.value07 = cardPwd;
            sysInfo.value08 = type.ToString();
            string  outValue = Service.GetOutValue("[ZP_Ports]", CodeHelper.xml(sysInfo));
            if (outValue.Substring(0,4)=="ZZ00")
            {
                reslut = true;
            }
            return reslut;
        }
    }
}
